public class Test {
    public static void main(String[] args) {
        String s="hello world!";
        String ss="haha";
        String str=" hh   ";
        System.out.println("字符串的长度为：");
        System.out.println(s.length());
        for(int i=0;i<s.length();i++) {
            System.out.println("第"+(i+1)+"个字符为：");
            System.out.println(s.charAt(i));
        }
        System.out.println("拼接两个字符串：");
        String sss=ss+s;
        System.out.println(sss);
        System.out.println("比较两个字符串：");
        System.out.println(s.compareTo(ss));
        System.out.println("替换字符串：");
        System.out.println(s.replace('l', 'm'));
        System.out.println("转换为大写：");
        System.out.println(s.toUpperCase());
        System.out.println("转换为小写：");
        System.out.println(s.toLowerCase());
        System.out.println("去掉两边空格：");
        System.out.println(str.trim());
        System.out.println("转换为字符数组:");
        char[] arr=s.toCharArray();
        for(int i=0;i<arr.length;i++) {
            System.out.print(arr[i]+" ");
        }
        System.out.println();
        System.out.println("转换为字节数组：");
        byte[] arr2=s.getBytes();
        for(int i=0;i<arr2.length;i++) {
            System.out.print(arr2[i]+" ");
        }
    }
}
